
<div style="padding: 20px">
    <a class="layui-btn" data-type="tabAdd" href="/admin/add">新增</a>
    <table class="layui-table" lay-data="{width: 'full-10', height: 'full-105', url:'/admin/contenttable', page:true}" lay-filter="demo">
        <thead>
        <tr>
            <th lay-data="{field:'id', width:65, fixed: true,sort:true}">Id</th>
            <th lay-data="{field:'account', width:160}">账号</th>
            <th lay-data="{field:'name', width:150}">账号名字</th>
        <th lay-data="{fixed:'right', width:200, align:'center', toolbar: '#barTool'}"></th>
        </tr>
        </thead>
    </table>
</div>
<script type="text/html" id="barTool">
    <a class="layui-btn layui-btn-mini" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del">删除</a>
</script>
<script>
    var $;
    layui.config({
        base : "js/"
    }).use(['table','element','layer','jquery'], function(){
        var table = layui.table;
        var element = layui.element;
        $ = layui.jquery
//监听工具条
        table.on('tool(demo)', function(obj){
            var data = obj.data;
             if(obj.event === 'del'){
                layer.confirm('真的删除【'+data.name+'】任务么', function(index){
                    var jsData = {'id':data.id}
                    $.post('{{urlfor "AdminController.AjaxDel"}}', jsData, function (out) {
                        if (out.status == 0) {
                            layer.alert('删除成功了', {icon: 1},function(index){
                                layer.close(index);
                                window.location.reload();
                            });
                        } else {
                            layer.msg(out.message)
                        }
                    }, "json");
                    // obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                 window.location.href="/admin/edit?id="+data.id
             }
        });
    });

</script>